home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11824 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.2 KB

  1. Path: newsfeed.pitt.edu!dsinc!ub!newserve!rebecca!rpi!not-for-mail
  2. From: rlister@pyramid.com (Robert Lister)
  3. Newsgroups: comp.lang.c++.moderated,comp.object,comp.lang.c++
  4. Subject: Re: how many classes are too much? trying to follow Robert Martin's advice
  5. Date: 16 Mar 1996 10:07:12 -0000
  6. Organization: Pyramid Technology
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: Dietmar.Kuehl@uni-konstanz.de
  9. Message-ID: <4ie3sg$2mp@netlab.cs.rpi.edu>
  10. References: <4hn86s$im4@netlab.cs.rpi.edu> <4i1fim$bm5@netlab.cs.rpi.edu> <4i3vlj$jcs@netlab.cs.rpi.edu>
  11. NNTP-Posting-Host: netlab.cs.rpi.edu
  12. X-Original-Date: 15 Mar 1996 10:13:12 -0800
  13.  
  14.  
  15. In article <4i3vlj$jcs@netlab.cs.rpi.edu>, ell@access4.digex.net (Ell) writes:
  16. |> Robert C. Martin (rmartin@oma.com) wrote:
  17. |> :...
  18. |> : Class proliferation is a real problem.  And it is often novices that
  19. |> : have to face it first.  However, the problem is not simply the number
  20. |> : of classes that the novice produces, but the way in which the novice
  21. |> : produces them.  The novice will say:  "Oh gee, I could use a class for
  22. |> : this, and that, and the other, and -- wow -- I could use a class for
  23. |> : all kinds of things."  The result is a whole bunch of classes
  24. |> : conglomerated together into a morrass of "Gee Whizes". 
  25. |> 
  26. |> A few classes may or may not be what is required.  The real question is
  27. |> what does the vocabulary of the domain require?  Whether or not the
  28. |> required number of domain vocabulary classes results in a "morass" depends
  29. |> on how how well the developer uses an architecture to pull things
  30. |> together. 
  31. |> 
  32. |> : The experienced designer does not proliferate classes on a whim.  He
  33. |> : does *exactly* what you have done.  He starts with a few classes, and
  34. |> : then partition them according to their convenient abstractions.  
  35. |> 
  36. |> Should the developer partition according to "convenient abstractions"  for
  37. |> "a few classes", gained at one phase of project iteration, and
  38. |> incrementation or according to the overall architecture of the project
  39. |> based on analysis vocabulary? 
  40. |> 
  41. |> : each partitioning, the designer ensures that the resultant code is
  42. |> : simpler and more resilient to change. 
  43. |> 
  44. |> This is one goal of an iterative, incremental cycle.  There are others
  45. |> also, such as coming closer to the vocabulary of the domain and 
  46. |> fulfilling more project requirements.  Both of which may or may not 
  47. |> require more classes.
  48. |> 
  49. |> : You saw me do this in my book.  In almost every case I would start
  50. |> : with just a few simple core abstractions, and then I would hunt for
  51. |> : the underlying abstractions that would allow me to partition the
  52. |> : design to my advantage.
  53. |> 
  54. |> However the point of development is not only, or primarily gaining
  55. |> advantage in terms of a lesser number of classes and their resilience to
  56. |> change, in an effort to give the code designer an advantage.
  57. |> 
  58. |> Secondly here, how are underlying abstractions different from and more 
  59. |> important than domain vocabulary abstractions?
  60. |> 
  61. |> Elliott
  62. |> 
  63. |>       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  64. |>       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  65. |>       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  66. |>       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  67.  
  68. In my experience each class you add costs a minimum of 500-1000 bytes
  69. of memory (even for a dinky little class that doesn't have anything
  70. except the compiler generated member functions).
  71.  
  72. I think it's a trade off between the strict type checking that 
  73. classes provide versus the memory they waste.
  74.  
  75. For example you might create a RangedInt base class and then
  76. derive classes from there with the specific ranges needed in
  77. your program (each class would derive from a class with a greater
  78. range).  Your compiler would prevent you from passing out of range
  79. integers to your functions.  Of course it would get silly if you
  80. have too many ranges.
  81.  
  82. That's kind of dumb example, but I think it illustrates the tradeoff.
  83.  
  84. - Bob
  85. -- 
  86. Robert Lister
  87.  
  88.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  89.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  90.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  91.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  92.